package com.my.coolq.strategy.message;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.my.coolq.strategy.ReceiveMessagesHandleStrategy;
import com.my.coolq.strategy.ReceiveMessagesHandleStrategySupport;
/**
 * 收到消息
 * @author ch
 *
 */
@Component
public class MessageHandleStrategy implements ReceiveMessagesHandleStrategy{
	
	private static final String POST_TYPE="message";
	
	@Autowired
	private ReceiveMessagesHandleStrategySupport receiveMessagesHandleStrategySupport;
	
	@Override
	public String getPostType() {
		return POST_TYPE;
	}

	@Override
	public Object handle(Map<String, Object> params) {
		ReceiveMessagesHandleStrategy receiveMessagesHandleStrategy = receiveMessagesHandleStrategySupport.getReceiveMessagesHandleStrategy(StringUtils.join(new String[]{POST_TYPE,String.valueOf(params.get("message_type"))},"_"));
		return receiveMessagesHandleStrategy==null?null:receiveMessagesHandleStrategy.handle(params);
	}

}
